<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="description" content="API docs for the getHistoryMessageList method from the TIMMessageManager class, for the Dart programming language.">
  <title>getHistoryMessageList method - TIMMessageManager class - tim_message_manager library - Dart API</title>


  
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet">
  
  <link rel="stylesheet" href="../../static-assets/github.css?v1">
  <link rel="stylesheet" href="../../static-assets/styles.css?v1">
  <link rel="icon" href="../../static-assets/favicon.png?v1">

  
</head>


<body data-base-href="../../" data-using-base-href="false" class="light-theme">

<div id="overlay-under-drawer"></div>

<header id="title">
  <span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="../../index.html">tencent_cloud_chat_sdk</a></li>
    <li><a href="../../native_im_adapter_tim_message_manager/native_im_adapter_tim_message_manager-library.html">native_im&#47;adapter&#47;tim_message_manager.dart</a></li>
    <li><a href="../../native_im_adapter_tim_message_manager/TIMMessageManager-class.html">TIMMessageManager</a></li>
    <li class="self-crumb">getHistoryMessageList method</li>
  </ol>
  <div class="self-name">getHistoryMessageList</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
  <div class="toggle" id="theme-button" title="Toggle brightness">
    <label for="theme">
      <input type="checkbox" id="theme" value="light-theme">
      <span id="dark-theme-button" class="material-symbols-outlined">
        dark_mode
      </span>
      <span id="light-theme-button" class="material-symbols-outlined">
        light_mode
      </span>
    </label>
  </div>
</header>
<main>

<div
    id="dartdoc-main-content"
    class="main-content"
    data-above-sidebar="native_im_adapter_tim_message_manager&#47;TIMMessageManager-class-sidebar.html"
    data-below-sidebar="">
    <div>
<h1><span class="kind-method">getHistoryMessageList</span> method 
</h1></div>

    <section class="multi-line-signature">
      

<span class="returntype"><a href="https://api.flutter.dev/flutter/dart-async/Future-class.html">Future</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="../../models_v2_tim_value_callback/V2TimValueCallback-class.html">V2TimValueCallback</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="https://api.flutter.dev/flutter/dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="../../models_v2_tim_message/V2TimMessage-class.html">V2TimMessage</a></span>&gt;</span></span>&gt;</span></span>&gt;</span></span>
<span class="name ">getHistoryMessageList</span>(<wbr><ol class="parameter-list"><li><span class="parameter" id="getHistoryMessageList-param-getType">{<span class="type-annotation"><a href="../../enum_history_msg_get_type_enum/HistoryMsgGetTypeEnum.html">HistoryMsgGetTypeEnum</a>?</span> <span class="parameter-name">getType</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-userID"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/String-class.html">String</a>?</span> <span class="parameter-name">userID</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-groupID"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/String-class.html">String</a>?</span> <span class="parameter-name">groupID</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-lastMsgSeq"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a>?</span> <span class="parameter-name">lastMsgSeq</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-count"><span>required</span> <span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a></span> <span class="parameter-name">count</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-lastMsgID"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/String-class.html">String</a>?</span> <span class="parameter-name">lastMsgID</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-messageTypeList"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a></span>&gt;</span>?</span> <span class="parameter-name">messageTypeList</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-messageSeqList"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a></span>&gt;</span>?</span> <span class="parameter-name">messageSeqList</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-timeBegin"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a>?</span> <span class="parameter-name">timeBegin</span>, </span></li>
<li><span class="parameter" id="getHistoryMessageList-param-timePeriod"><span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/int-class.html">int</a>?</span> <span class="parameter-name">timePeriod</span>}</span></li>
</ol>)

      

    </section>
    


    
<section class="summary source-code" id="source">
  <h2><span>Implementation</span></h2>
  <pre class="language-dart"><code class="language-dart">Future&lt;V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt;&gt; getHistoryMessageList({
  HistoryMsgGetTypeEnum? getType,
  String? userID,
  String? groupID,
  int? lastMsgSeq,
  required int count,
  String? lastMsgID,
  List&lt;int&gt;? messageTypeList,
  List&lt;int&gt;? messageSeqList,
  int? timeBegin,
  int? timePeriod,
}) async {
  if (!TIMManager.instance.isInitSDK()) {
    return V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt;(code: TIMErrCode.ERR_SDK_NOT_INITIALIZED.value, desc: &quot;sdk not init&quot;);
  }

  if ((userID == null || userID.isEmpty) &amp;&amp; (groupID == null || groupID.isEmpty)) {
    return V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt;(code: TIMErrCode.ERR_INVALID_PARAMETERS.value, desc: &quot;invalid userID and groupID&quot;);
  }

  V2TimMessage? lastMessage;
  if (lastMsgID != null) {
    V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt; findResult = await findMessages(messageIDList: [lastMsgID]);
    if (findResult.code != TIMErrCode.ERR_SUCC.value) {
      print(&quot;getHistoryMessageList, find last message failed&quot;);
      return V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt;(code: findResult.code, desc: findResult.desc);
    }

    List&lt;V2TimMessage&gt; msgList = findResult.data!;
    if (msgList.isNotEmpty) {
      lastMessage = msgList[0];
    }
  }

  String userData = Tools.generateUserData(&#39;getHistoryMessageList&#39;);
  Completer&lt;V2TimValueCallback&lt;List&lt;V2TimMessage&gt;&gt;&gt; completer = Completer();
  NativeLibraryManager.timValueCallback2Future&lt;List&lt;V2TimMessage&gt;&gt;(userData, completer);

  String convID = &#39;&#39;;
  TIMConvType convType = TIMConvType.kTIMConv_Group;
  if (groupID != null &amp;&amp; groupID.isNotEmpty) {
    convID = groupID;
    convType = TIMConvType.kTIMConv_Group;
  } else {
    convID = userID!;
    convType = TIMConvType.kTIMConv_C2C;
  }

  V2TimMessageGetHistoryMessageListParam param = V2TimMessageGetHistoryMessageListParam(count: count, getType: getType, lastMessage: lastMessage, lastMessageSeq: lastMsgSeq, timeBegin: timeBegin, timePeriod: timePeriod, messageTypeList: messageTypeList, messageSeqList: messageSeqList);
  Pointer&lt;Char&gt; pParam = Tools.string2PointerChar(json.encode(param.toJson()));
  Pointer&lt;Char&gt; pConvID = Tools.string2PointerChar(convID);
  Pointer&lt;Void&gt; pUserData = Tools.string2PointerVoid(userData);
  NativeLibraryManager.bindings.DartGetHistoryMessageList(pConvID, convType, pParam, pUserData);

  return completer.future;
}</code></pre>
</section>


  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
    <!-- The search input and breadcrumbs below are only responsively visible at low resolutions. -->
<header id="header-search-sidebar" class="hidden-l">
  <form class="search-sidebar" role="search">
    <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
    <li><a href="../../index.html">tencent_cloud_chat_sdk</a></li>
    <li><a href="../../native_im_adapter_tim_message_manager/native_im_adapter_tim_message_manager-library.html">tim_message_manager</a></li>
    <li><a href="../../native_im_adapter_tim_message_manager/TIMMessageManager-class.html">TIMMessageManager</a></li>
    <li class="self-crumb">getHistoryMessageList method</li>
</ol>


    <h5>TIMMessageManager class</h5>
    <div id="dartdoc-sidebar-left-content"></div>
  </div><!--/.sidebar-offcanvas-->

  <div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
</div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    tencent_cloud_chat_sdk
      8.5.6864-beta.7
  </span>

  
</footer>



<script src="../../static-assets/highlight.pack.js?v1"></script>
<script src="../../static-assets/docs.dart.js"></script>



</body>

</html>

